/**
 * zmn产品模块-产品列表
 * @author tanghongjun
 * @since 2018/10/18
 */
layui.define(['index', 'form', 'zmnApp', 'table', 'laypage', 'laydate', 'layedit'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;
    let zmnApp = layui.zmnApp;
    let laydate = layui.laydate;

    table.init('zmn-table', {
        toolbar: "#zmn-table-tool",
        page: true,
        limit: json.pageSize,
        height: 'full-149'
    });
    laypage.render(layui.$.extend({limits:[10, 20, 30, 40, 50,100]},zmnPage.laypageOptions(json)));

    let ids = new Array();

    // 选择（全选或单选）
    table.on("checkbox(zmn-table)", function (obj) {
        ids = table.checkStatus('zmn-table').data.map((item) => item.logId);
    });

    laydate.render({
        elem: '#createTime',
        format: 'yyyy-MM-dd',
    });

    // 手动重置表单数据
    $(document).on('click', '#zmn-form-reset ', function () {
        let typeSelect = "<option value=\"\">-选择-</option>";
        if (json.changeTypeList != null && json.changeTypeList.length > 0) {
            for (let i = 0; i < json.changeTypeList.length; i++) {
                let exAttr = "";
                let exText = "";
                typeSelect += '<option value="' + json.changeTypeList[i].key + '" ' + exAttr + '>' + json.changeTypeList[i].value + " " + exText + '</option>';
            }
        }
        $("#changeType").html(typeSelect);
        form.render();
    });

    // 启用/停用
    table.on("toolbar(zmn-table)", function (obj) {
        //启用停用
        if (obj.event != "start" && obj.event != "stop") {
            return false;
        }
        if (ids.length === 0) {
            return layer.alert("请选择至少1条数据！");
        }
        zmnPage.layStartStop(obj, zmnApp.SYS_BASE_URL +"/staff/staffchangelog/updateStatus.action", ids.join(","));
    });

    //对外暴露的接口
    exports('plat_staffchangelog_list', {});
});

